<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>多媒体画廊 - 优雅展示您的照片与视频</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"/>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        :root {
            --primary: #8a2be2;
            --secondary: #ff6b6b;
            --dark: #1a1a2e;
            --light: #f8f9fa;
            --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        body {
            background: linear-gradient(135deg, var(--dark), #16213e);
            color: var(--light);
            min-height: 100vh;
            overflow-x: hidden;
            padding-bottom: 50px;
        }

        header {
            text-align: center;
            padding: 2rem 1rem;
            position: relative;
            z-index: 10;
        }

        h1 {
            font-size: 2.8rem;
            margin-bottom: 0.5rem;
            background: linear-gradient(to right, var(--secondary), var(--primary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 2px 10px rgba(138, 43, 226, 0.2);
        }

        .subtitle {
            font-size: 1.1rem;
            opacity: 0.8;
            max-width: 600px;
            margin: 0 auto;
            line-height: 1.6;
        }

        .gallery-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }

        /* 移动端卡片样式 */
        .mobile-gallery {
            display: none;
            height: 75vh;
            position: relative;
            perspective: 1000px;
            margin: 0 auto;
            max-width: 400px;
        }

        .swiper {
            width: 100%;
            height: 100%;
            padding-top: 40px;
        }

        .swiper-slide {
            background-position: center;
            background-size: cover;
            width: 280px;
            border-radius: 20px;
            overflow: hidden;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
            transform: rotate(calc(var(--swiper-slide-index) * 4deg - 8deg)) scale(calc(0.9 - 0.05 * var(--swiper-slide-index))) translateY(calc(var(--swiper-slide-index) * 15px - 30px));
            transition: var(--transition);
            opacity: 0.9;
            filter: brightness(0.9);
            position: relative;
        }

        .swiper-slide-active {
            transform: rotate(0deg) scale(1) translateY(0);
            opacity: 1;
            filter: brightness(1);
            z-index: 10;
        }

        .card-content {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
            padding: 20px;
            color: white;
            transform: translateY(100px);
            transition: var(--transition);
        }

        .swiper-slide-active .card-content {
            transform: translateY(0);
        }

        .card-title {
            font-size: 1.4rem;
            margin-bottom: 8px;
        }

        .card-description {
            font-size: 0.95rem;
            opacity: 0.9;
            line-height: 1.5;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.5s ease;
        }

        .swiper-slide-active .card-description {
            max-height: 100px;
        }

        .card-media {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .video-icon {
            position: absolute;
            top: 15px;
            right: 15px;
            background: var(--primary);
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 2;
            box-shadow: 0 0 15px rgba(138, 43, 226, 0.5);
        }

        /* 网页端平铺视图 */
        .desktop-gallery {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 25px;
            margin-top: 20px;
        }

        .gallery-item {
            border-radius: 15px;
            overflow: hidden;
            height: 300px;
            position: relative;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            transform: scale(0.95);
            transition: var(--transition);
            cursor: pointer;
        }

        .gallery-item:hover {
            transform: scale(1.05);
            box-shadow: 0 15px 40px rgba(138, 43, 226, 0.4);
            z-index: 2;
        }

        .gallery-item .card-content {
            transform: translateY(0);
            padding: 15px;
        }

        .gallery-item .card-title {
            font-size: 1.2rem;
        }

        .gallery-item .card-description {
            max-height: 50px;
            font-size: 0.9rem;
        }

        /* 详情模态框 */
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.9);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.4s ease;
        }

        .modal.active {
            opacity: 1;
            pointer-events: all;
        }

        .modal-content {
            width: 90%;
            max-width: 900px;
            max-height: 90vh;
            background: var(--dark);
            border-radius: 20px;
            overflow: hidden;
            position: relative;
            transform: scale(0.8);
            transition: transform 0.4s ease;
        }

        .modal.active .modal-content {
            transform: scale(1);
        }

        .modal-media {
            width: 100%;
            max-height: 70vh;
            object-fit: contain;
            display: block;
        }

        .modal-info {
            padding: 20px;
        }

        .modal-title {
            font-size: 1.8rem;
            margin-bottom: 10px;
            color: var(--secondary);
        }

        .modal-description {
            font-size: 1.1rem;
            line-height: 1.6;
            opacity: 0.9;
        }

        .close-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 40px;
            height: 40px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 1.5rem;
            transition: var(--transition);
            backdrop-filter: blur(5px);
            z-index: 10;
        }

        .close-btn:hover {
            background: var(--secondary);
            transform: rotate(90deg);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .mobile-gallery {
                display: block;
            }
            .desktop-gallery {
                display: none;
            }
            h1 {
                font-size: 2.2rem;
            }
            .subtitle {
                font-size: 1rem;
            }
        }

        .footer-note {
            text-align: center;
            margin-top: 40px;
            opacity: 0.7;
            font-size: 0.9rem;
        }

        /* 加载动画 */
        .loader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--dark);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1001;
            transition: opacity 0.5s, visibility 0.5s;
        }

        .loader.hidden {
            opacity: 0;
            visibility: hidden;
        }

        .loader-circle {
            width: 80px;
            height: 80px;
            border: 5px solid rgba(138, 43, 226, 0.2);
            border-top: 5px solid var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* 导航控制 */
        .swiper-button-prev, .swiper-button-next {
            color: var(--primary) !important;
            background: rgba(255, 255, 255, 0.2);
            width: 40px !important;
            height: 40px !important;
            border-radius: 50%;
            backdrop-filter: blur(5px);
        }

        .swiper-button-prev::after, .swiper-button-next::after {
            font-size: 1.2rem !important;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <!-- 加载动画 -->
    <div class="loader">
        <div class="loader-circle"></div>
    </div>

    <header>
        <h1><i class="fas fa-camera-retro"></i> 时光记忆画廊</h1>
        <p class="subtitle">滑动浏览珍贵的照片与视频，每一帧都是我们的故事</p>
    </header>

    <div class="gallery-container">
        <!-- 移动端卡片视图 -->
        <div class="mobile-gallery">
            <div class="swiper">
                <div class="swiper-wrapper">
                    <!-- 卡片将通过JS动态生成 -->
                </div>
                <div class="swiper-button-prev"></div>
                <div class="swiper-button-next"></div>
            </div>
        </div>

        <!-- 网页端平铺视图 -->
        <div class="desktop-gallery">
            <!-- 项目将通过JS动态生成 -->
        </div>
    </div>

    <!-- 详情模态框 -->
    <div class="modal">
        <div class="modal-content">
            <div class="close-btn">
                <i class="fas fa-times"></i>
            </div>
            <img class="modal-media" src="" alt="">
            <video class="modal-media" controls></video>
            <div class="modal-info">
                <h2 class="modal-title"></h2>
                <p class="modal-description"></p>
            </div>
        </div>
    </div>

    <p class="footer-note">用心记录每一个美好瞬间 ❤️ | 设计与开发：多媒体画廊</p>

    <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
    <script>
        // 模拟数据 - 实际应用中可替换为真实数据
        const mediaItems = [
            {
                id: 1,
                type: 'image',
                url: 'https://images.unsplash.com/photo-1501854140801-50d01698950b?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '山间日出',
                description: '清晨的第一缕阳光洒在山间，温暖而宁静，让人感受到大自然的壮丽与美好。'
            },
            {
                id: 2,
                type: 'video',
                url: 'https://assets.mixkit.co/videos/preview/mixkit-waves-in-the-water-1164-large.mp4',
                poster: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '海浪拍岸',
                description: '海浪轻轻拍打着岸边，带来宁静与放松的感觉，仿佛能听到大海的声音。'
            },
            {
                id: 3,
                type: 'image',
                url: 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '森林迷雾',
                description: '晨雾中的森林神秘而美丽，阳光穿透树叶形成的光束如梦似幻。'
            },
            {
                id: 4,
                type: 'video',
                url: 'https://assets.mixkit.co/videos/preview/mixkit-city-traffic-at-night-3451-large.mp4',
                poster: 'https://images.unsplash.com/photo-1483653364400-eedcfb9f1f88?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '城市夜景',
                description: '夜晚的城市灯火辉煌，车流穿梭，展现都市的繁华与活力。'
            },
            {
                id: 5,
                type: 'image',
                url: 'https://images.unsplash.com/photo-1465146344425-f00d5f5c8f07?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '秋日小路',
                description: '金黄的落叶铺满小路，漫步其中感受秋天的气息和宁静。'
            },
            {
                id: 6,
                type: 'image',
                url: 'https://images.unsplash.com/photo-1476820865390-c52aeebb9891?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '星空璀璨',
                description: '夜空中的繁星点点，银河清晰可见，令人感叹宇宙的浩瀚与神秘。'
            },
            {
                id: 7,
                type: 'video',
                url: 'https://assets.mixkit.co/videos/preview/mixkit-sunset-over-a-lake-3445-large.mp4',
                poster: 'https://images.unsplash.com/photo-1506260408121-e353d10b87c7?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '湖面日落',
                description: '夕阳西下，湖面映照着金色的余晖，构成一幅宁静而壮美的画面。'
            },
            {
                id: 8,
                type: 'image',
                url: 'https://images.unsplash.com/photo-1418065460487-3e41a6c84dc5?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80',
                title: '热带雨林',
                description: '茂密的热带雨林生机勃勃，各种植物交织生长，展现大自然的神奇。'
            }
        ];

        // DOM元素
        const mobileGallery = document.querySelector('.swiper-wrapper');
        const desktopGallery = document.querySelector('.desktop-gallery');
        const modal = document.querySelector('.modal');
        const closeBtn = document.querySelector('.close-btn');
        const modalMedia = document.querySelectorAll('.modal-media');
        const modalTitle = document.querySelector('.modal-title');
        const modalDescription = document.querySelector('.modal-description');
        const loader = document.querySelector('.loader');

        // 生成移动端卡片
        function generateMobileCards() {
            mediaItems.forEach(item => {
                const slide = document.createElement('div');
                slide.className = 'swiper-slide';
                
                let mediaElement;
                if (item.type === 'image') {
                    mediaElement = document.createElement('img');
                    mediaElement.src = item.url;
                } else {
                    mediaElement = document.createElement('video');
                    mediaElement.poster = item.poster;
                    mediaElement.setAttribute('data-src', item.url);
                }
                
                mediaElement.className = 'card-media';
                slide.appendChild(mediaElement);
                
                if (item.type === 'video') {
                    const videoIcon = document.createElement('div');
                    videoIcon.className = 'video-icon';
                    videoIcon.innerHTML = '<i class="fas fa-play"></i>';
                    slide.appendChild(videoIcon);
                }
                
                const content = document.createElement('div');
                content.className = 'card-content';
                content.innerHTML = `
                    <h3 class="card-title">${item.title}</h3>
                    <p class="card-description">${item.description}</p>
                `;
                slide.appendChild(content);
                
                slide.addEventListener('click', () => openModal(item));
                mobileGallery.appendChild(slide);
            });
        }

        // 生成网页端平铺项目
        function generateDesktopItems() {
            mediaItems.forEach(item => {
                const galleryItem = document.createElement('div');
                galleryItem.className = 'gallery-item';
                
                let mediaElement;
                if (item.type === 'image') {
                    mediaElement = document.createElement('img');
                    mediaElement.src = item.url;
                } else {
                    mediaElement = document.createElement('video');
                    mediaElement.poster = item.poster;
                    mediaElement.setAttribute('data-src', item.url);
                }
                
                mediaElement.className = 'card-media';
                galleryItem.appendChild(mediaElement);
                
                if (item.type === 'video') {
                    const videoIcon = document.createElement('div');
                    videoIcon.className = 'video-icon';
                    videoIcon.innerHTML = '<i class="fas fa-play"></i>';
                    galleryItem.appendChild(videoIcon);
                }
                
                const content = document.createElement('div');
                content.className = 'card-content';
                content.innerHTML = `
                    <h3 class="card-title">${item.title}</h3>
                    <p class="card-description">${item.description}</p>
                `;
                galleryItem.appendChild(content);
                
                galleryItem.addEventListener('click', () => openModal(item));
                desktopGallery.appendChild(galleryItem);
            });
        }

        // 打开模态框显示详情
        function openModal(item) {
            // 隐藏所有媒体元素
            modalMedia.forEach(el => el.style.display = 'none');
            
            if (item.type === 'image') {
                modalMedia[0].src = item.url;
                modalMedia[0].style.display = 'block';
            } else {
                modalMedia[1].src = item.url;
                modalMedia[1].style.display = 'block';
                modalMedia[1].play();
            }
            
            modalTitle.textContent = item.title;
            modalDescription.textContent = item.description;
            modal.classList.add('active');
            document.body.style.overflow = 'hidden';
        }

        // 关闭模态框
        function closeModal() {
            modal.classList.remove('active');
            document.body.style.overflow = 'auto';
            
            // 暂停视频播放
            const video = modalMedia[1];
            if (video) {
                video.pause();
                video.currentTime = 0;
            }
        }

        // 初始化Swiper
        function initSwiper() {
            const swiper = new Swiper('.swiper', {
                effect: 'cards',
                grabCursor: true,
                centeredSlides: true,
                loop: true,
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
            });
        }

        // 初始化页面
        function initPage() {
            generateMobileCards();
            generateDesktopItems();
            initSwiper();
            
            // 添加事件监听
            closeBtn.addEventListener('click', closeModal);
            modal.addEventListener('click', (e) => {
                if (e.target === modal) closeModal();
            });
            
            // 隐藏加载动画
            setTimeout(() => {
                loader.classList.add('hidden');
            }, 800);
            
            // 添加滚动效果（网页端）
            if (window.innerWidth > 768) {
                const items = document.querySelectorAll('.gallery-item');
                
                items.forEach(item => {
                    const observer = new IntersectionObserver((entries) => {
                        entries.forEach(entry => {
                            if (entry.isIntersecting) {
                                item.style.transform = 'scale(1)';
                            } else {
                                item.style.transform = 'scale(0.95)';
                            }
                        });
                    }, {
                        threshold: 0.1
                    });
                    
                    observer.observe(item);
                });
            }
        }

        // 页面加载完成后初始化
        window.addEventListener('load', initPage);
    </script>
</body>
</html>